package com.renfei.jnithread;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.renfei.jnithread.util.PThread;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {

    @BindView(R.id.tv_normal_thread)
    TextView tvNormalThread;
    @BindView(R.id.tv_produce_and_consumption)
    TextView tvProduceAndConsumption;
    @BindView(R.id.tv_c_transfer_java)
    TextView tvCTransferJava;


    private PThread pThread;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

        pThread = new PThread();
        pThread.setOnErrorListener(new PThread.onErrorListener() {
            @Override
            public void onError(int code, String msg) {
                Log.e("renfei666","code is  "+code+"\n"
                +"msg is    "+msg);
            }
        });
    }

    @OnClick({R.id.tv_normal_thread, R.id.tv_produce_and_consumption, R.id.tv_c_transfer_java})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_normal_thread:
                pThread.createNormalThread();
                break;
            case R.id.tv_produce_and_consumption:
                pThread.createProduceAndConsumption();
                break;
            case R.id.tv_c_transfer_java:
                pThread.callBackFromC();
                break;
        }
    }


}
